


//1.自定义一级品类下拉列表
var selectOff = true;
//selectWrapper();
function selectWrapper(){
	var $select_wrapper = $('.category-wrap'),
		$selectlist_wrapper = $('.selectlist-wrapper'),
		$selectlist_li = $('.selectlist-wrapper li');
		
	$select_wrapper.click(function(e){	
		if(selectOff){
			$(this).addClass('active');
			$selectlist_wrapper.slideDown();
			selectOff = false;
		}else{
			$(this).removeClass('active');
			$selectlist_wrapper.slideUp();
			selectOff = true;
		}
		e.stopPropagation();
	});
	//选中下拉列表中选项
	$selectlist_li.click(function(e){
		//标记选中
		$selectlist_li.removeClass('selected');
		$(this).addClass('selected');
		
		$select_wrapper.removeClass('active');
		$select_wrapper.find('input').val($(this).text());
		
		$selectlist_wrapper.slideUp();
		selectOff = true;
		e.stopPropagation();
	});
	
	
	//收起下拉列表
	$(document).click(function(){
		$selectlist_wrapper.slideUp();
		$select_wrapper.removeClass('active');
		selectOff = true;
	});
	$(document).scroll(function(){
		$selectlist_wrapper.slideUp();
		$select_wrapper.removeClass('active');
		selectOff = true;
	});
}
	
	
	


//2.固定搜索栏
var searchOffTop = $('.main').offset().top,
	$main_search = $('.main .main-search'),
	$selectlist_wrapper = $('.selectlist-wrapper');
$(window).scroll(function(){
	scrollFun();
});
scrollFun();	
function scrollFun(){
	var scrollTop = $(this).scrollTop();
	if(scrollTop>searchOffTop){
		$main_search.addClass('fixed');
		$selectlist_wrapper.addClass('fixed');
	}else{
		$main_search.removeClass('fixed');
		$selectlist_wrapper.removeClass('fixed');
	}
}





//3.品类选择窗口
win_category();
function win_category(){
	var $category_wrapper = $('.main .category-wrap'),
		$win_category = $('.site-category'),
		$win_close = $('.site-category .win-close'),
		$win_cate = $('.site-category .cate'),
		$category = $('#category');
		
	$category_wrapper.click(function(){
		hiddenScroll();
		$win_category.slideDown();
	});
	$win_close.click(function(){
		overScroll();
		$win_category.slideUp();
	});
	
	
	$win_cate.click(function(){
		$win_cate.removeClass('active');
		$(this).addClass('active');
		
		$category.val($(this).text());
		
		$win_close.trigger('click');
	});
	
}



